--我即烈日
local wojilieri = fk.CreateSkill {
    name = "mcdh_wojilieri"
}

wojilieri:addEffect('active',{
    card_num = 0,
    target_num = 0,
    card_filter = Util.FalseFunc,
    can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
    on_use = function(self, room, effect)
        local player  = effect.from
        local targets = table.filter(room:getAlivePlayers(true), function(p) return not p:isKongcheng() end)
        local extraData = {
            num = 1,
            min_num = 1,
            include_equip = false,
            pattern = ".",
            reason = self.name,
        }

        local req = Request:new(targets, "AskForUseActiveSkill")
        local data = { "choose_cards_skill", "#wojilieri-card", false, extraData }
        req.focus_text = "#wojilieri-card"
        for _, p in ipairs(targets) do
            local DefaultReply = {
                card={
                    skill="choose_cards_skill",
                    subcards={table.random(p:getCardIds("h"))}
                },
                target = {}
            }
            req:setData(p,  data)
            req:setDefaultReply(p,DefaultReply)
        end

        for _, p in ipairs(targets) do
            local replyCard = req:getResult(p).card
            local id = replyCard.subcards[1]
            room:setPlayerMark(p, "wojilieri-tmp", id)
        end

        for _, p in ipairs(targets) do
            if not p.dead then
                local id = p:getMark("wojilieri-tmp")
                p:showCards({ id })
            end
        end
        room:delay(500)
        local canDiscards = table.filter(player:getCardIds("he"),function(id) return not player:prohibitDiscard(id)  end)
        if #canDiscards >= 1 then
            local  _ ,ret = room:askForUseActiveSkill(player, "#mcdh_wojilieri_discard_skill", "#wojilieri-discard", false)
            local toDiscard
            if ret then
                toDiscard = ret.cards
            else
                toDiscard = table.random(canDiscards, 1)
            end
            room:throwCard(toDiscard, self.name, player, player)
            for _, p in ipairs(targets) do
                if not p.dead then
                    local id = p:getMark("wojilieri-tmp")
                    if Fk:getCardById(id).suit == Fk:getCardById(toDiscard[1]).suit then
                        room:damage({
                            from = player,
                            to = p,
                            damage = 1,
                            skillName = self.name,
                            damageType = fk.FireDamage,
                        })
                    end
                end
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_wojilieri"] = "我即烈日",
    [":mcdh_wojilieri"] = "出牌阶段限一次，你可以令所有角色同时展示一张手牌，然后你弃置一张牌,对展示牌与弃置牌相同花色的角色造成1点火焰伤害。",
    ["#wojilieri-card"] = "我即烈日:展示一张手牌",
    ["#wojilieri-discard"] = "我即烈日:弃置一张牌,对展示牌与弃置牌相同花色的角色造成1点火焰伤害。",
    ["#mcdh_wojilieri_discard_skill"] ="我即烈日" ,
}


return wojilieri